﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentManagement.Models;
using System.ComponentModel;
using System.Windows;
using System.Windows.Data;

namespace DocumentManagement.ViewsModels
{
  public  class ReportDocumentOutToDivisionViewsModel : ViewsModelBase
    {

       public QSHCEntities1 _entityModels;
        public QSHCEntities1 EntityModels
        {
            get { return _entityModels; }
            set
            {
                if (_entityModels != value)
                {
                    _entityModels = value;
                    OnPropertyChanged("EntityModels");
                }
            }
        }

        //private Send _mySend;
        //public Send MySend
        //{
        //    get { return _mySend; }
        //    set
        //    {
        //        if (_mySend != value)
        //        {
        //            _mySend = value;
        //            OnPropertyChanged("MySend");

        //            //if (MyReceive != null)
        //            //    MyReceiveICV = CollectionViewSource.GetDefaultView(EntityModels.Receives.Where(p => p.Active == true).ToList());
        //        }
        //    }
        //}
     


        public ICollectionView _mySendICV;
        public ICollectionView MySendICV
        {
            get { return _mySendICV; }
            set
            {
                if (_mySendICV != value)
                {
                    _mySendICV = value;
                    OnPropertyChanged("MySendICV");
                }
            }
        }

        private int _myText1;
        public int MyText1
        {
            get { return _myText1; }
            set
            {
                if (_myText1 != value)
                {
                    _myText1 = value;
                    OnPropertyChanged("MyText1");
                }
            }
        }
        private int _myText2;
        public int MyText2
        {
            get { return _myText2; }
            set
            {
                if (_myText2 != value)
                {
                    _myText2 = value;
                    OnPropertyChanged("MyText2");
                }
            }
        }
        private int _myText3;
        public int MyText3
        {
            get { return _myText3; }
            set
            {
                if (_myText3 != value)
                {
                    _myText3 = value;
                    OnPropertyChanged("MyText3");
                }
            }
        }
        private int _myTextDivisionID;
        public int MyTextDivisionID
        {
            get { return _myTextDivisionID; }
            set
            {
                if (_myTextDivisionID != value)
                {
                    _myTextDivisionID = value;
                    OnPropertyChanged("MyTextDivisionID");
                }
            }
        }
        public ReportDocumentOutToDivisionViewsModel()
        {
            if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                EntityModels = new QSHCEntities1();


                //CurrentDivisionID = EntityModels.Divisions.Where(p => p.DivisionID == )
                //MySendICV = CollectionViewSource.GetDefaultView(EntityModels.Sends.Where(p => p.Active == true).ToList()); //.Where(p => p.Active == true)

                //MyText1 = EntityModels.Sends.Count(p => p.Active == true);
                //MyText2 = EntityModels.Sends.Count(p => p.Status == 1);
                //MyText3 = EntityModels.Sends.Count(p => p.Status == 2);

            }
        }
        public void CheckTODivisionID()
        {
            //MessageBox.Show(MyTextDivionID.ToString());
            MySendICV = CollectionViewSource.GetDefaultView(EntityModels.CreateSends.Where(p => p.ToDivisionID == MyTextDivisionID).Where(p => p.Active==true).ToList()); //.Where(p => p.Active == true)
            MyText1 = EntityModels.CreateSends.Where(p => p.ToDivisionID == MyTextDivisionID).Where(p => p.Active == true).Count();//EntityModels.Receives.Count(p => p.Active == true);
            MyText2 = EntityModels.CreateSends.Where(p => p.ToDivisionID == MyTextDivisionID).Where(p => p.Type == 1).Where(p => p.Active==true).Count();//EntityModels.Receives.Count(p => p.Status == 1);
            MyText3 = EntityModels.CreateSends.Where(p => p.ToDivisionID == MyTextDivisionID).Where(p => p.Type == 2).Where(p => p.Active==true).Count();//EntityModels.Receives.Count(p => p.Status == 2);

        }
        //public ReportDocumentINFromDivisionViewsModel()
        //{
        //    if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
        //    {
        //        EntityModels = new QSHCEntities1();


        //        //CurrentDivisionID = EntityModels.Divisions.Where(p => p.DivisionID == )
        //        MyReceiveICV = CollectionViewSource.GetDefaultView(EntityModels.Receives.Where(p => p.Active == true).ToList()); //.Where(p => p.Active == true)

        //        MyText1 = EntityModels.Receives.Count(p => p.Active == true);
        //        MyText2 = EntityModels.Receives.Count(p => p.Status == 1);
        //        MyText3 = EntityModels.Receives.Count(p => p.Status == 2);

        //    }
        //}
    }
}
